package logic

import (
	"cart_srv/model/redis"
	"context"

	"cart_srv/cart"
	"cart_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartFlushLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartFlushLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartFlushLogic {
	return &CartFlushLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartFlushLogic) CartFlush(in *cart.CartFlushRequest) (*cart.CartFlushResponse, error) {
	// todo: add your logic here and delete this line
	//if !redis.CartIsExists(in.UserId) {
	//	logx.Error("该购物车是空的")
	//	return nil, nil
	//}
	redis.CartFlush(in.UserId)
	return &cart.CartFlushResponse{}, nil
}
